package com.api.gbhg.daiyanlu.Dao;

import weaver.conn.RecordSet;

import java.util.HashMap;
import java.util.Map;

public class BudgerProcessDao {
    //核批任务
    public static Map<String, Integer> getDataCount(int nd,int state,String dw){
        RecordSet rs = new RecordSet();
        String sql ;
        if (dw.equals("2")){
            sql = "select (select count(id) cut from uf_jingfei_version where sfwdlhsdw = "+state+" and lcztz = 3 and ysnd = "+nd+") processed,count(id) unprocessed \n" +
                    "from  uf_jingfei_version where sfwdlhsdw ="+state+" and lcztz != 3 and ysnd = "+nd+"; ";
        }else{
            sql = "select (select count(id) cut from uf_jingfei_version where sfwdlhsdw = "+state+" and lcztz = 3 and ysnd = "+nd+" and sbdw in ("+dw+")) processed,count(id) unprocessed \n" +
                    "from  uf_jingfei_version where sfwdlhsdw ="+state+" and lcztz != 3 and ysnd = "+nd+" and sbdw in ("+dw+")   ; ";
        }

        rs.executeQuery(sql);
        rs.next();
        Map<String, Integer> map = new HashMap();
        map.put("processed", rs.getInt("processed"));
        map.put("unprocessed", rs.getInt("unprocessed"));
        return map;
    }

    //预算执行
    public static RecordSet getTotalImplement(int nd, int state,String dw) {
        RecordSet rs = new RecordSet();
        String sql ;
        if (dw.equals("2")){
            sql = "select SUM(jf.ze) ze,SUM(jf.syed) syed from \n" +
                    " uf_jingfei jf join uf_jingfei_version jv on jf.requestId = jv.requestId \n" +
                    " where jf.nd = "+nd+" and jv.sfwdlhsdw = "+state+"  ";
        }else{
            sql = "select SUM(jf.ze) ze,SUM(jf.syed) syed from \n" +
                    " uf_jingfei jf join uf_jingfei_version jv on jf.requestId = jv.requestId \n" +
                    " where jf.nd = "+nd+" and jv.sfwdlhsdw = "+state+" and jf.sbdw in ("+dw+")  ";
        }

        rs.executeQuery(sql);
        rs.next();
        return rs;
    }
}
